<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/bootstrap.min.js"></script>
    <script src="../../static/js/bootstrap-datetimepicker.min.js"></script>
    <script src="../../static/js/bootstrap-datetimepicker.zh-CN.js"></script>
    <!--<script src="http://cdn.bootcss.com/highlight.js/8.0/highlight.min.js"></script>
    <script src="../../static/js/smoothscroll.js"></script>
    <script src="../../static/js/mking.js"></script>-->
    <link href="http://cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel="stylesheet">
    <!--<link rel="stylesheet" href="../../static/css/heightlength.css">
    <link rel="stylesheet" href="../../static/css/mxjs.css">-->
    <link rel="stylesheet" href="../../static/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" href="../../static/css/heightlength.css">
    <!--<link rel="stylesheet" href="../../static/css/mxjs.css">-->
    <style>
        body{
            /*width: 100%;*/
            height: 100%;
        }
        .container{
            height: 95%;
        }
        *{
            color: grey;
        }
        .form-control {
            width: 40%;
            /*margin-left: 12%;*/
            display: flex;
            flex-direction: column;
        }
        label{
            width: 20%;
        }
    </style>
</head>
<body>

<div class="col-lg-12 mxlength">
    <div class="mx-1" >
        <span >当前位置>> <i id="show">未完成体检查询</i></span>
        <span id="ret" style="float: right;margin-right: 3%;color: black" hidden onclick="cl()"><a ><i>返回</i></a></span>
    </div>
</div>
<div class="col-lg-12"  id="tj" style="margin-left: 20px"">

<span style="">请选择查询条件</span>

<table width="100%" style="width: 700px;">
<tr>
    <td colspan="4"></td>
</tr>
<tr>
    <td style="text-align: right">开始时间:</td>
    <td><input style="width: 80%;color: grey" type="text" class="form-control form_datetime" id="statime" name="time"  placeholder=""></td>
    <td style="text-align:right ">结束时间:</td>
    <td><input type="text" style="width: 80%" class="form-control form_datetime" id="endtime" name="time" value=""  placeholder="" style="float: right"></td>
</tr>


</table>
<button onclick="cx()" style="margin-left: 5%">查询</button>
</div>
<div class="col-lg-12  "  id="res" hidden>
    <span style="">您输入的条件为：<i id="time"></i> &nbsp;&nbsp;共有<i id="count"></i>条数据</span>
    <table style="width: 100%" border="1" cellpadding="0" cellspacing="0">
        <thead>
        <th>体检编码</th>
        <th>身份证号</th>
        <th width="70px">姓名</th>
        <th width="40">性别</th>
        <th width="40">年龄</th>
        <th width="40">部门</th>
        <th width="40">工号</th>
        <th width="100px">体检日期</th>
        <th>缺检项目</th>
        </thead>
        <tbody id="tb">

        </tbody>
    </table>


</div>
<script>
    $(function () {

        if (document.referrer=="") {
            $("#bb").hide();
            var hostname=location.hostname;
            var port=location.port;
            var trueUri="http://"+hostname+":"+port+"/dw/"
            window.location.href=trueUri;
        }

        // alert(window.location.href);

    });
    $('.form_datetime').datetimepicker({
        minView: "month",  //选择日期后，不会再跳转去选择时分秒
        language:  'zh-CN',
        format : 'yyyy-mm-dd',//日期显示格式
        //  timeFormat:'',//时间显示格式
        //  todayBtn:  1,
        autoclose: 1,
        pickerPosition: 'bottom-left'
    });
    $('#selectAll').change(function(){
        $('.fa').children(':checkbox').prop('checked',$(this).is(':checked')?true:false);
    });
    function cx() {
        var start=$("#statime").val();
        var end=$("#endtime").val();
        //debugger;
        if (start==end) {
            alert("开始时间和结束时间一致，请重新选择");
            return false;
        }
        if (start==null || start==undefined || start==""){
            alert("请选择开始时间");
            return false;
        }
        if (end==null || end==undefined || end=="") {
            alert("请选择结束时间");
            return false;
        }
        if (pd(start,end)) {
            $.ajax({
                url: 'wwctjcxs',
                type: "POST",
                traditional: true,
                data: {start: start, end: end},
                success: function (data) {
                    $("#ret").show();
                    $("#tj").hide();
                    $("#res").show();
                    $("#tb").empty();
                    $("#show").text("未完成体检查询结果");
                    $("#time").text(start + "--" + end);
                    debugger
                    if (data.status != "false") {
                        $("#count").text(data.data.length);
                        for (var i = 0; i < data.data.length; i++) {
                            var str = "";
                            $.each(data.data, function (commendIndex, comment) {
                                str += "<tr>" +
                                    "<td>" + comment['tjbm'] + "</td>" +
                                    "<td>" + comment['idc'] + "</td>" +
                                    "<td>" + comment['name'] + "</td>" +
                                    "<td>" + comment['sex'] + "</td>" +
                                    "<td>" + comment['age'] + "</td>";
                                if (comment['dpt'] != null) {
                                    str += "<td>" + comment['dpt'] + "</td>";
                                } else {
                                    str += "<td></td>";
                                }
                                if (comment['wrknum'] != null) {
                                    str += "<td>" + comment['wrknum'] + "</td>";
                                } else {
                                    str += "<td></td>";
                                }
                                if (comment['bhkdat'] != null) {
                                    str += "<td>" + comment['bhkdat'] + "</td>";
                                } else {
                                    str += "<td></td>";
                                }
                                str += "<td>" + comment['wwcxm'] + "</td>" +
                                    "</tr>";
                            });
                            $("#tb").append(str);
                        }
                    } else {
                        $("#count").text(data.data.length);
                        $("#tb").append("<tr><td colspan='9' style='text-align: center'> 暂无未完成体检信息</td></tr")
                    }

                }
            })
        }else {
            alert("开始时间不能大于结束时间");
            return false;
        }
    }
    function  cl() {
        $("#tb").empty();
        $("#res").hide();
        $("#tj").show();
        $("#ret").hide();
        $("#time").empty();
        $("#count").empty();
    }
    function pd(start,end) {
        var startTmp = start.split("-");
        var endTmp = end.split("-");
        var stT = new Date(startTmp[0], startTmp[1], startTmp[2]);
        var edT = new Date(endTmp[0], endTmp[1], endTmp[2]);
        if (stT.getTime() >edT.getTime()) {
            //alert("开始日期不能大于或等于结束日期！");
            return false;
        }else {
            return true;
        }
    }
</script>
</body>
</html>